﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using TRPOP.CMS.Model;
using TRPOP.CMS.DALFactory;
using TRPOP.Config;
using TRPOP.Common;
using System.Data;

namespace TRPOP.CMS.DALSQLServer
{
    public class CommonManage
    {
        private TRPOP.ComSqlDAL.ICommonDAL Idal;

        public CommonManage()
        {
            Idal = DataAccess.CreateCommon();
        }

        /// <summary>
        /// 自定义列表（分页）
        /// </summary>
        /// <param name="strTableName"></param>
        /// <param name="strShowColumns"></param>
        /// <param name="pageNumber"></param>
        /// <param name="pageSize"></param>
        /// <param name="condition"></param>
        /// <param name="orderby"></param>
        /// <param name="recordCount"></param>
        /// <returns></returns>
        public DataSet GetListByPager(string strTableName, string strShowColumns, int pageNumber, int pageSize, string condition, string orderby, out int recordCount)
        {
            return Idal.GetListByPager(strTableName, strShowColumns, pageNumber, pageSize, condition, orderby, out  recordCount, SystemInfoHelper.getSystemInfo().CMSDataBaseConnection);
        }

        /// <summary>
        /// 执行SQL语句
        /// </summary>
        /// <param name="strSqlString"></param>
        /// <returns></returns>
        public EnumSubmitResult ExeSQLQuery(string strSqlString)
        {
            return Idal.ExeSQLQuery(strSqlString, SystemInfoHelper.getSystemInfo().CMSDataBaseConnection);
        }

        /// <summary>
        /// 泛型 获取列表
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="strSelectQuery"></param>
        /// <returns></returns>
        public List<T> GetListByCondition<T>(string strSelectQuery)
        {
            return Idal.GetListByCondition<T>(strSelectQuery, SystemInfoHelper.getSystemInfo().CMSDataBaseConnection);
        }

        /// <summary>
        /// 获取dataset
        /// </summary>
        /// <param name="strSelectQuery"></param>
        /// <returns></returns>
        public DataSet GetDataSet(string strSelectQuery)
        {
            return Idal.GetDataSet(strSelectQuery, SystemInfoHelper.getSystemInfo().CMSDataBaseConnection);
        }
    }
}
